<template>
  <div class="right-container">
    <!--    组件顶部统计数据-->
    <div class="right-top">
      <div
        v-for="(item, index) in totalitem"
        :key="index"
        class="total-container"
      >
        <div class="total-container-top">{{ item.number }}人</div>
        <div class="total-container-foot">{{ item.type }}</div>
      </div>
    </div>
    <!--    组件中间饼状图部分-->
    <div class="right-bottom">
      <div id="myChart"></div>
      <div class="bottom-item">
        <div class="item-container" v-for="(item, index) in 6" :key="index">
          <div class="item-left">在村工作</div>
          <div class="item-right">详情</div>
        </div>
      </div>
    </div>
    <!--    图片部分-->
    <div class="right-foot">
      <div class="img1">
        <img src="../assets/img/img1.jpg" width="100%" height="100%" />
      </div>
      <div class="img-container">
        <div class="img2">
          <img src="../assets/img/img2.jpg" width="100%" height="100%" />
        </div>
        <div class="img3">
          <img src="../assets/img/img3.jpg" width="100%" height="100%" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "right",
  data() {
    return {
      totalitem: [
        {
          type: "流出人口",
          number: 70,
        },
        {
          type: "流入人口",
          number: 70,
        },
        {
          type: "旅客人数",
          number: 70,
        },
        {
          type: "在村工作",
          number: 70,
        },
        {
          type: "在村工作",
          number: 70,
        },
        {
          type: "在村工作",
          number: 70,
        },
      ],
    };
  },
  mounted() {
    this.drawLine();
  },
  methods: {
    drawLine() {
      // 基于准备好的dom，初始化echarts实例
      const myChart = this.$echarts.init(document.getElementById("myChart"));
      // 绘制图表
      myChart.setOption({
        title: {
          text: "在村工作",
          left: "left",
          textStyle: {
            fontSize: 12,
            color: "#ffffff",
          },
        },
        series: [
          {
            type: "pie",
            radius: "70%",
            label: {
              show: false,
            },
            data: [
              {
                value: 1048,
                name: "1",
              },
              {
                value: 735,
                name: "2",
              },
              {
                value: 580,
                name: "3",
              },
            ],
          },
        ],
      });
    },
  },
};
</script>

<style scoped>
.right-container {
  background-color: rgba(81, 84, 87, 0.2);
  height: 600px;
  width: 300px;
}

.right-top {
  display: flex;
  flex-wrap: wrap;
  height: 20%;
  width: 100%;
}

.right-bottom {
  display: flex;
  height: 20%;
  width: 100%;
}

.right-foot {
  height: 60%;
  width: calc(100% + 17px);
  overflow: auto;
}

.total-container {
  height: 50%;
  width: 33.33%;
}

.total-container-top {
  background-color: rgba(43, 43, 43, 0.8);
  color: rgb(152, 185, 94);
  text-align: center;
  height: 50%;
  width: 100%;
}

.total-container-foot {
  color: white;
  text-align: center;
  height: 50%;
  width: 100%;
}

#myChart {
  width: 120px;
  height: 120px;
}

.bottom-item {
  display: flex;
  flex-wrap: wrap;
  width: 180px;
  height: 100%;
}

.item-container {
  display: flex;
  width: 50%;
  height: 33.33%;
}

.item-left {
  background-color: rgba(0, 120, 215, 0.3);
  border-radius: 5px;
  color: white;
  font-size: 10px;
  text-align: center;
  line-height: 20px;
  width: 60%;
  height: 20px;
}

.item-right {
  color: white;
  font-size: 10px;
  text-align: center;
  line-height: 20px;
  width: 40%;
  height: 20px;
}

.img1 {
  width: 100%;
  height: 50%;
}

.img-container {
  display: flex;
  width: 100%;
  height: 50%;
}

.img2 {
  width: 50%;
  height: 100%;
}

.img3 {
  width: 50%;
  height: 100%;
}
</style>
